<template>
	<view class="list-box">
		<!-- 我的赠送或我的领取 商品 -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type<3&&current==0">
			<view class="t-top">
				<img :src="item.pic||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.prodName||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
							<text v-if="item.price">{{item.units?`/${item.units}`:''}}</text>
							<text v-else>{{item.units?item.units:''}}</text>
						</view>
						<view class="t-money-rt">
							x{{ item.num||'' }}
						</view>
					</view>
					<view class="t-name">
						收货人：{{ item.takePeople||'' }}
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的赠送 代金券 -->
		<view class="right-item right-item2" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==1&&current==1">
			<img class="t-status"
				:src="item.useStatus==0&&item.userOpenId==null?couponStatusImgStatus[0]:item.useStatus==0&&item.userOpenId?couponStatusImgStatus[1]:couponStatusImgStatus[2]"
				alt="">

			<view class="t-top">
				<view class="t-info">
					<view class="t-title">
						{{ item.name ||''}}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的领取 代金券 -->
		<view class="right-item right-item2" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==2&&current==1">
			<img class="t-status" :src="item.useStatus==0?couponStatusImgStatus[0]:couponStatusImgStatus[2]" alt="">
			<view class="t-top">
				<view class="t-info">
					<view class="t-title">
						{{ item.name ||''}}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的赠送 大礼包 -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==1&&current==2">
			<img class="t-status"
				:src="item.useStatus==0&&item.userOpenId==null?couponStatusImgStatus[0]:item.useStatus==0&&item.userOpenId?couponStatusImgStatus[1]:couponStatusImgStatus[2]"
				alt="">
			<view class="t-top">
				<img :src="item.image||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.name||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
					<view class="t-name t-name-time">
						{{ item.createTime ||''}}
					</view>
				</view>
			</view>
		</view>
		<!-- 我的领取 大礼包 -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==2&&current==2">
			<img class="t-status" :src="item.useStatus==0?couponStatusImgStatus[0]:couponStatusImgStatus[2]" alt="">
			<view class="t-top">
				<img :src="item.image||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.name||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
					<view class="t-name t-name-time">
						{{ item.createTime ||''}}
					</view>
				</view>
			</view>
		</view>

		<!-- 我的售出  -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)" v-show="type==3">
			<view class="t-top">
				<img :src="item.pic||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.prodName||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
							<text v-if="item.price">{{item.units?`/${item.units}`:''}}</text>
							<text v-else>{{item.units?`${item.units}`:''}}</text>
						</view>
						<view class="t-money-rt">
							x{{ item.num||'' }}
						</view>
					</view>
					<view class="t-name">
						收货人：{{ item.takePeople||'' }}
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的购买  -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)" v-show="type==4">
			<view class="t-top">
				<img :src="item.pic||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.prodName||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
							<text v-if="item.price">{{item.units?`/${item.units}`:''}}</text>
							<text v-else>{{item.units?`${item.units}`:''}}</text>
						</view>
						<view class="t-money-rt">
							x{{ item.num||'' }}
						</view>
					</view>
					<!-- <view class="t-name">
						收货人：{{ item.name }}
					</view> -->
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				//优惠券领取状态照片
				couponStatusImgStatus: [
					'https://file.casugn.com/storecompcard//puMCCZBjY0NFf20e585cd67837d1fb0b4d169c695c66_1705286971097.png',
					'https://file.casugn.com/storecompcard//rFciu4kTExbReea3b8a18ade5f13f1da6c83db3a4753_1705287241061.png',
					'https://file.casugn.com/storecompcard//a4bJbKghXzBh202ed71f60e1b134eb21bb644774c316_1705287286207.png'
				],
			};
		},
		props: {
			// dataList: Array,
			// type: Number,
			// current: Number,

			dataList: {
				type: Array,
				required: true,
				default: () => [],
			},
			type: {
				type: Number,
				required: true,
				default: 0,
			},
			current: {
				type: Number,
				required: true,
				default: 0,
			},
		},
		onShow() {
			console.log(dataList)
		},
		methods: {
			regLink(e) {
				console.log(e, 'index');
				console.log(this.type, '左侧点击')
				console.log(this.current, '右侧点击')

				// 我的赠送 商品跳转详情
				if (this.type == 1 && this.current == 0) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/sendDetail?id=${e.id}&type=${this.type}&current=${this.current}`
					})
				}
				// 我的领取 商品跳转详情
				if (this.type == 2 && this.current == 0) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/sendDetail?id=${e.id}&type=${this.type}&current=${this.current}`
					})
				}
				// 我的赠送 代金券跳转详情
				if (this.type == 1 && this.current == 1) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}
				// 我的领取 代金券跳转详情
				if (this.type == 2 && this.current == 1) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}



				// 我的赠送 大礼包跳转详情
				if (this.type == 1 && this.current == 2) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}
				// 我的领取 大礼包跳转详情
				if (this.type == 2 && this.current == 2) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}

				// 我的售出 待发货已发货跳转详情
				if (this.type == 3) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}
				// 我的购买 待发货已发货跳转详情
				if (this.type == 4) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}




				// const pageNum = getCurrentPages()
				// console.log('navigateTo pageNum: ', pageNum.length)
				// if (pageNum.length > 9) {
				// 	switch (e) {
				// 		case 0:
				// 			uni.redirectTo({
				// 				url: `/pagesMall/mallCenter/mallCenter`
				// 			})
				// 			break;
				// 		case 1:
				// 			uni.redirectTo({
				// 				url: `/pagesMall/myShop/myShop`
				// 			})
				// 			break;
				// 		case 2:
				// 			uni.redirectTo({
				// 				url: `/pagesMall/myOrder/orderList`
				// 			})
				// 			break;
				// 	}

				// } else {
				// 	switch (e) {
				// 		case 0:
				// 			uni.navigateTo({
				// 				url: `/pagesMall/mallCenter/mallCenter`
				// 			})
				// 			break;
				// 		case 1:
				// 			uni.navigateTo({
				// 				url: `/pagesMall/myShop/myShop`
				// 			})
				// 			break;
				// 		case 2:
				// 			uni.navigateTo({
				// 				url: `/pagesMall/myOrder/orderList`
				// 			})
				// 			break;
				// 	}

				// }

			},
		}
	}
</script>

<style scoped lang="scss">
.list-box {
	padding: 20rpx;
}

.right-item {
	background: #ffffff;
	border-radius: 16rpx;
	margin-bottom: 20rpx;
	position: relative;
	padding: 24rpx;
	box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
	transition: all 0.3s ease;

	&:active {
		transform: scale(0.99);
		box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
	}

	&:last-child {
		margin-bottom: 0;
	}

	.t-status {
		position: absolute;
		width: 102rpx;
		height: 102rpx;
		top: 0;
		right: 0;
		z-index: 2;
	}

	.t-top {
		display: flex;
		align-items: flex-start;
		margin-bottom: 20rpx;

		img {
			width: 160rpx;
			height: 160rpx;
			border-radius: 12rpx;
			flex-shrink: 0;
			background-color: #f5f5f5;
		}

		.t-info {
			margin-left: 24rpx;
			flex: 1;
			min-width: 0;

			.t-title {
				font-size: 28rpx;
				font-weight: 600;
				color: #303133;
				line-height: 1.4;
				margin-bottom: 12rpx;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				line-clamp: 2;
				-webkit-box-orient: vertical;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			.t-money {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-bottom: 12rpx;

				.t-money-lt {
					font-size: 28rpx;
					font-weight: 600;
					color: #ff4757;
					line-height: 1;

					text {
						font-size: 24rpx;
						font-weight: 400;
						color: #ff4757;
					}
				}

				.t-money-rt {
					font-size: 24rpx;
					font-weight: 400;
					color: #909399;
					line-height: 1;
				}
			}

			.t-name {
				font-size: 24rpx;
				font-weight: 400;
				color: #909399;
				line-height: 1.3;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.t-name-time {
				color: #c0c4cc;
			}
		}
	}

	.t-time {
		font-size: 24rpx;
		font-weight: 400;
		color: #c0c4cc;
		line-height: 1;
		text-align: right;
	}

	}

// 代金券特殊样式
.right-item2 {
	.t-top {
		display: block;
		margin-bottom: 16rpx;

		.t-info {
			margin-left: 0;
			border-bottom: 1rpx dashed #e5e6eb;
			padding-bottom: 20rpx;
			
			.t-title {
				font-size: 28rpx;
				font-weight: 600;
				color: #303133;
				line-height: 1.4;
				margin-bottom: 16rpx;
			}

			.t-money {
				margin-bottom: 0;
				
				.t-money-lt {
					font-size: 30rpx;
					font-weight: 600;
					color: #ff4757;
				}
			}
		}
	}
}
</style>